//
// Created by longyunbo on 6/23/21.
//

#include "ConstantPool.h"




ConstantPool ::~ConstantPool(){

//    if( _klass == nullptr ){
//        delete _klass;
//    }
    if( _tags == nullptr ){
        delete _tags;
    }
    if( _container == nullptr ){
        delete _container;
    }

};
//得到Klass
Klass ConstantPool::get_Klass(){
    return _klass;
}
//设置Klass
void ConstantPool::set_Klass(Klass value){
    _klass = value;
}
//初始化函数
void ConstantPool::initContainer(short size){
    _size = size;

    _tags = new char[size];
    _container = new long[size];

    //显示中这两个位置没什么作用

    _tags[0] = 0;
    _container[0] = 0;
}
//设置长度
void ConstantPool::set_length(short value){
    _length = value;
}
short ConstantPool::get_length(){
    return _length;
};

//存值 char*
void ConstantPool::add_item( int i , char tag , char* value ){
    _tags[i] = tag;
    _container[i] =(long)value;
};
//add_item 存储Long
void ConstantPool::add_item( int i , char tag , long value ){
    _tags[i] = tag;
    _container[i] =value;
};

//存储位运算的值
void ConstantPool::add_item( int i , char tag , int value , int ii ){
    _tags[i] = tag;
    _container[i] =value;
};

//取值
long ConstantPool::get_item( int i ){
    return _container[i];
};

//得到类名
long ConstantPool::getClassName( int index ){
    return get_item((short)get_item(index) );;
};




